import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * @creationDate 2019/12/25
 */
import request from "../../utils/request";
import { getEnvConfig } from "../../utils/iocUtils";
import { getCurrentOrganizationId, isTenantRoleLevel } from "../../utils/utils";

var _getEnvConfig = getEnvConfig(),
    CPAAS_PLATFORM = _getEnvConfig.CPAAS_PLATFORM;
/**
 * 查询静态文本数据 不会报 400 异常, 异常全是 200
 * 需要自己处理异常(自己调用getResponse)
 * {CPAAS_PLATFORM}/v1/static-texts/text/by-code/nullable
 * @param {string} textCode - 静态文本编码
 * @param {string} [lang=currentLanguage] - 语言 默认是系统当前语言
 * @return {Promise}
 */


export function queryStaticText(_x) {
  return _queryStaticText.apply(this, arguments);
}
/**
 * 获取模板配置提示信息详情
 */

function _queryStaticText() {
  _queryStaticText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(textCode) {
    var lang,
        organizationId,
        organizationRoleLevel,
        _args = arguments;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            lang = _args.length > 1 && _args[1] !== undefined ? _args[1] : 'dict';
            organizationId = getCurrentOrganizationId();
            organizationRoleLevel = isTenantRoleLevel();
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationRoleLevel ? "".concat(organizationId, "/") : '', "static-texts/text/by-code/nullable"), {
              query: {
                textCode: textCode,
                lang: lang
              },
              method: 'GET'
            }));

          case 4:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryStaticText.apply(this, arguments);
}

export function queryToolTip(_x2) {
  return _queryToolTip.apply(this, arguments);
}

function _queryToolTip() {
  _queryToolTip = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    var organizationId;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            organizationId = getCurrentOrganizationId();
            return _context2.abrupt("return", request(isTenantRoleLevel() ? "".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/static-texts/text-code") : "".concat(CPAAS_PLATFORM, "/v1/static-texts/text-code"), {
              method: 'GET',
              query: params
            }));

          case 2:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _queryToolTip.apply(this, arguments);
}